<admintpl file="header" xmlns="http://www.w3.org/1999/html"/>
</head>
<body>
<div class="wrap">
    <form method="post" class="form-horizontal " id="myform" enctype="multipart/form-data"  action="{:U('Admin/NewsManage/addFull')}">
         <div class="control-group">
            <label class="span1 control-label" style="width: 90px;">标题</label>
            <div class="span3">
            	<input type="text" name="title" value="{$news_info.full_title}" id="title">
            </div>
        </div>

		<div class="control-group">
			<label class="span1 control-label" style="width: 90px;">副标</label>
			<div class="span3">
				<input type="text" name="subtitle" value="{$news_info.full_subtitle}" id="subtitle">
			</div>
		</div>

		<div class="control-group">
			<label class="span1 control-label" style="width: 90px;">封面图片：</label>
			<div class="span4 wrapper" style="float:left">
				<div id="uploader-image">
					<div id="fileList" class="uploader-list">
						<div id="imageDiv" class="file-item thumbnail" style="width:150px;height: 150px;">
							<?php
										if(!empty($news_info['full_cover_image'])){
									?>
							<img id="imagePreview" name="" src="{$news_info.full_cover_image}" style="width:150px;height: 140px;">
							<?php
										}else{
										?>
							<img id="imagePreview" src="__PUBLIC__/images/furley_bg.png" style="width:150px;height: 140px;">
							<?php
										}
										?>
							<div id="picker" class="info">选择图片&nbsp;&nbsp;&nbsp;&nbsp;</div>
							<input style="display:none;" type="file" id="imageFile" name="imageFile" >
						</div>
					</div>
				</div>
			</div>
			<div style="color:red;float:left;margin-top:140px">*通栏图片  尺寸：984*328  格式：JPG/PNG</div>
		</div>
        
        
		<input type="hidden" name="news_id" id="news_id" value="<?php echo $news_id;?>">
		<input type="hidden" name="column_id" id="column_id" value="<?php echo $column_id;?>">
		<input type="hidden" name="is_area" id="is_area" value="<?php echo $is_area;?>">
		<input type="hidden" name="status"  id="status" value="">
		<input type="hidden" name="special_news_id"  id="special_news_id" value="<?php echo $special_news_id;?>">
		<input type="hidden" name="hidimg" value="{$news_info.full_cover_image}">
        <div class="form-actions" style="padding-left:260px;">
			<input type="button" class="btn btn-primary" id="ajaxform"value="保存" onclick="save_full(1)"></input>
			<input type="button"  class="btn btn-primary" value="清空并保存" id="ajaxform" onclick="save_full(0)"></input>
            &nbsp;&nbsp;<a class="btn" id="ajaxback">{:L('BACK')}</a>
        </div>
    </form>
</div>
<script src="__PUBLIC__/js/common.js"></script>
<script type="text/javascript" src="__PUBLIC__/js/content_addtop.js"></script>
<script type="text/javascript" src="__PUBLIC__/js/ueditor/ueditor.config.js"></script>
<script type="text/javascript" src="__PUBLIC__/js/ueditor/ueditor.all.min.js"></script>
<script type="text/javascript"
        src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.10.0/jquery.validate.min.js"></script>
<script src="__PUBLIC__/js/layer/layer.js"></script>
<script>

	function save_full(status){    // 提交按钮触发事件
		var tourl = $("#myform").attr("action");    // 获取 表单的 提交地址
		var title = $("#title").val();
		var subtitle  = $("#subtitle").val();
		var cover_img = $("#cover_img").val();
		var news_id   = $("#news_id").val();
		var column_id = $("#column_id").val();
		var is_area   = $("#is_area").val();
		if(status == 1){
			var flag = false;
			var data = [];
			data.push(title);
			data.push(subtitle);
			$.ajax({
				type:"post",
				async:false,
				url:"./index.php?g=admin&m=Movement&a=filter_words",
				data:'data='+data,
				dataType:"text",
				success:function(data){
					if(data){
						if(confirm('您编辑的内容涉及敏感词'+data+'是否继续操作')){
							flag= true;
							return true;
						}else{
							flag= false;
							return false;
						}
					}else{
						flag = true;
						return true;
					}
				}
			});
			if(flag == false){
				return false;
			}
		}
		$("#status").val(status);
		$("#myform").submit();
//		return true;
//		$("#myform").submit(function (result){
////alert(result)
////		})
////		$.post(tourl,{title:title,subtitle:subtitle,cover_img:cover_img,news_id:news_id,status:status},function(result){
//        	if(result == '1'){
        		var msg = '设置成功';
//        	}else{
//        		var msg = '设置失败';
//        	}
//
    		if(flag == true){
				parent.layer.msg(msg,{time:2000},1,function(a){

				});
				setTimeout(function(){
					var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
					parent.layer.close(index);
				}, 1000);
				return true;
			}
//		});
	}
$(function(){
	$("[name='administrator_checbox']").click(function(){
		var administrator_id = $(this).val();
		var administrator_name = $(this).attr('administrator_name');

		var administrator_hidden_ids = $("#administrator_hidden_ids").val();
		var administrator_values = $("#administrator").val();

		var ids_arr = administrator_hidden_ids.split(",");         
		var values_arr = administrator_values.split(",");   
		
		if(ids_arr.indexOf(administrator_id) == '-1'){
			administrator_hidden_ids+=administrator_id+',';
			administrator_values+=administrator_name+',';
			$("#administrator").val(administrator_values);
			$("#administrator_hidden_ids").val(administrator_hidden_ids);
		}else{
			$.each(ids_arr,function(index,item){
				 if(item==administrator_id){
					 ids_arr.splice(index,1);
					 values_arr.splice(index,1);
				 }
			}) 
			administrator_hidden_ids = ids_arr.join(",");
			administrator_values = values_arr.join(",");
			$("#administrator").val(administrator_values);
			$("#administrator_hidden_ids").val(administrator_hidden_ids);
		}
	})
})
	function html5Reader(file, previewId){
		var file = file.files[0];
		var reader = new FileReader();
		reader.readAsDataURL(file);
		reader.onload = function(e){
			$('#'+previewId).attr('src', this.result);
		}
	}
	function image_change(fileId, previewId) {
		var pic = document.getElementById(previewId),
				file = document.getElementById(fileId);

		var ext = file.value.substring(file.value.lastIndexOf(".")+1).toLowerCase();

		// gif在IE浏览器暂时无法显示
		if(ext != 'png' && ext != 'jpg' && ext != 'jpeg'){
			alert("图片的格式必须为png或者jpg或者jpeg格式！");
			return;
		}
		var isIE = navigator.userAgent.match(/MSIE/)!= null,
				isIE6 = navigator.userAgent.match(/MSIE 6.0/)!= null;

		if(isIE) {
			file.select();
			var realLocalPath = document.selection.createRange().text;

			// IE6浏览器设置img的src为本地路径可以直接显示图片
			if (isIE6) {
				pic.src = realLocalPath;
			}else {
				// 非IE6版本的IE由于安全问题直接设置img的src无法显示本地图片，但是可以通过滤镜来实现
				pic.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod='image',src=\"" + realLocalPath + "\")";
				// 设置img的src为base64编码的透明图片 取消显示浏览器默认图片
				pic.src = '';
			}
		}else {
			html5Reader(file, previewId);
		}
	}

	$("#picker").click(function(){
		$("#imageFile").click();
	});

	$("#imageFile").change(function(){
		image_change('imageFile', 'imagePreview');
	});
// ajax 提交表单
$(document).ready(function(){

    $("#ajaxback").click(function(){
    	var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
		parent.layer.close(index);
    });
});
</script>
</body>
</html>